package research.ui.editors.tableeditors.calander;

import research.domain.Parameter;
import research.entity.Entity;
import research.ui.editors.tableeditors.EntityCellModifier;
import research.ui.editors.tableeditors.EntityLabelProvider;
import research.ui.editors.tableeditors.EntityTableEditor;

public class CalanderCellModifier extends EntityCellModifier {

	public CalanderCellModifier(EntityTableEditor viewer) {
		super(viewer);
	}

	@Override
	protected Object getValue(Entity entity, int columnIndex) {
		Parameter par = (Parameter) entity;

		switch (columnIndex) {
		case 0:
			return EntityLabelProvider.render(par.getName());
		case 1:
			return EntityLabelProvider.render(par.getUnits());
		case 2:
			return EntityLabelProvider.render(par.getLow());
		case 3:
			return EntityLabelProvider.render(par.getHigh());
		case 4:
			return EntityLabelProvider.render(par.getDescription());
		default:
		}
		return null;
	}

	@Override
	protected void modify(Entity entity, int columnIndex, Object value) {
		Parameter par = (Parameter) entity;
		switch (columnIndex) {
		case 0:
			par.setName(parseString(value));
			break;
		case 1:
			par.setUnits(parseString(value));
			break;
		case 2:
			par.setLow(parseDouble(value));
			break;
		case 3:
			par.setHigh(parseDouble(value));
			break;
		case 4:
			par.setDescription(parseString(value));
			break;
		default:
		}
	}

}
